package com.xique.door.service.impl;

import java.util.List;

import com.xique.common.core.text.Convert;
import com.xique.common.core.utils.DateUtils;
import com.xique.common.core.utils.SecurityUtils;
import com.xique.door.bean.domain.Company;
import com.xique.door.mapper.CompanyMapper;
import com.xique.door.service.ICompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 用户企业表Service业务层处理
 *
 * @author ww
 * @date 2021-12-21
 */
@Service
public class CompanyServiceImpl implements ICompanyService
{
    @Autowired
    private CompanyMapper companyMapper;

    /**
     * 查询用户企业表
     *
     * @param id 用户企业表ID
     * @return 用户企业表
     */
    @Override
    public Company selectCompanyById(Long id)
    {
        return companyMapper.selectCompanyById(id);
    }

    /**
     * 查询用户企业表列表
     *
     * @param company 用户企业表
     * @return 用户企业表
     */
    @Override
    public List<Company> selectCompanyList(Company company)
    {
        return companyMapper.selectCompanyList(company);
    }

    /**
     * 新增用户企业表
     *
     * @param company 用户企业表
     * @return 结果
     */
    @Override
    public int insertCompany(Company company)
    {
        company.setCreateTime(DateUtils.getNowDate());
        company.setUpdateTime(company.getCreateTime());
        company.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        company.setUpdateBy(company.getCreateBy());
        return companyMapper.insertCompany(company);
    }

    /**
     * 修改用户企业表
     *
     * @param company 用户企业表
     * @return 结果
     */
    @Override
    public int updateCompany(Company company)
    {
        company.setUpdateTime(DateUtils.getNowDate());
        company.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return companyMapper.updateCompany(company);
    }

    /**
     * 批量删除用户企业表
     *
     * @param ids 需要删除的用户企业表ID
     * @return 结果
     */
    @Override
    public int deleteCompanyByIds(String ids)
    {
        return companyMapper.deleteCompanyByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户企业表信息
     *
     * @param id 用户企业表ID
     * @return 结果
     */
    @Override
    public int deleteCompanyById(Long id)
    {
        return companyMapper.deleteCompanyById(id);
    }
}
